{% extends "admin/change_list.html" %}
{% load admin_list i18n cms_admin cms_js_tags %}
{% block title %}{% trans "List of pages" %}{% endblock %}
{% block bodyclass %}change-list{% endblock %}

{% if not is_popup %}{% block breadcrumbs %}
  <ul class="breadcrumb">
    <li><a href="../../">{% trans 'Home' %}</a>
      <span class="divider">&raquo;</span></li>
    <li>
    <li><a href="../">{{ app_label|capfirst|escape }}</a>
    <span class="divider">&raquo;</span></li>
    <li class="active">
    {{ opts.verbose_name_plural|capfirst|escape }}
    </li>
    </ul>
{% endblock %}{% endif %}

{% block coltype %}flex{% endblock %}
{% block extrahead %}
<link rel="stylesheet" type="text/css" href="{{ STATIC_URL }}cms/css/pages.css"/>
<link rel="stylesheet" type="text/css" href="{{ STATIC_URL }}cms/jstree/tree_component.css" />
<link rel="stylesheet" type="text/css" href="{{ STATIC_URL }}cms/css/jquery.dialog.css" />

{{ block.super }}
<script type="text/javascript" src="{% static_url %}js/jquery.min.js"></script>
<script type="text/javascript" src="{{ STATIC_URL }}cms/js/csrf.js"></script>
<script type="text/javascript" src="{{ STATIC_URL }}cms/js/libs/jquery.livequery.js"></script>

<script type="text/javascript" src="{{ STATIC_URL }}cms/js/libs/jquery.ui.core.js"></script>
<script type="text/javascript" src="{{ STATIC_URL }}cms/js/libs/jquery.bind.js"></script>
<script type="text/javascript" src="{{ STATIC_URL }}cms/js/libs/jquery.ui.checkbox.js"></script>
<script type="text/javascript" src="{{ STATIC_URL }}cms/js/libs/jquery.ui.effects.core.js"></script>
<script type="text/javascript" src="{{ STATIC_URL }}cms/js/libs/jquery.ui.effects.highlight.js"></script>
<script type="text/javascript" src="{{ STATIC_URL }}cms/js/libs/jquery.form.js"></script>
<script type="text/javascript" src="{{ STATIC_URL }}cms/jstree/_lib/_all.js"></script>
<script type="text/javascript" src="{{ STATIC_URL }}cms/jstree/tree_component.js"></script>
<script type="text/javascript" src="{{ STATIC_URL }}cms/js/libs/jquery.ui.dialog.js"></script>
<script type="text/javascript" src="{{ STATIC_URL }}cms/js/libs/jquery.functional.js"></script>
<script type="text/javascript" src="{{ STATIC_URL }}cms/js/libs/classy.min.js"></script>
<script type="text/javascript" src="{{ STATIC_URL }}cms/js/plugins/cms.setup.js"></script>
<script type="text/javascript" src="{{ STATIC_URL }}cms/js/plugins/cms.base.js"></script>
<script type="text/javascript" src="{{ STATIC_URL }}cms/js/change_list.js"></script>


{% if cl.is_filtered %}
<link rel="stylesheet" type="text/css" href="{{ STATIC_URL }}cms/jstree/themes/default/style.css" />
{% endif %}
<link rel="stylesheet" type="text/css" href="{{ STATIC_URL }}suit/css/djangocms.css">
{% endblock %}




{% block content %}
<script type="text/javascript">
//<![CDATA[	
(function namespacing($) {
	$(document).ready(function() {
		{% if not cl.is_filtered %}
			initTree();
		{% endif %}		
	});
	
	showchangelistfilter = function(){
		$("#changelist-filter").toggle();
	}
	moveSuccess = function(node){
		var msg = $({% javascript_string %}<span class="success">{% trans "Successfully moved" %}</span>{% end_javascript_string %});
		node.append(msg);
        // This should not happen
        if (node.parent().hasClass('publisher_delete_requested'))
            return;
        node.parent().addClass('publisher_dirty');
        if (!node.parent().find('.col-draft .publish').length) {
            var page_id = node.parent().parent().attr('id').replace('page_', '');
            node.parent().find('.col-draft').prepend(
                    '<a href="./'+page_id+'/publish/" class="icon publish" title="{% trans 'Publish' %}"></a>');
        }
	    msg.fadeOut(3000);
	}
	moveError = function(node,message){
        if(message && message!="error") {
            var msg = $({% javascript_string %}<span class="success">{% end_javascript_string %}+message+{% javascript_string %}</span>{% end_javascript_string %});
        }
        else {
            var msg = $({% javascript_string %}<span class="success">{% trans "An error occured. Please reload the page" %}</span>{% end_javascript_string %});
        }
		node.append(msg);
	}
	// some settings used by javascript functions

	cmsSettings = {
		cmsPermission: {{ CMS_PERMISSION|js }},
		debug: {{ DEBUG|js }}
	};
})(window.CMS.$);
//]]>
</script>


<div id="content-main"{% if cl.is_filtered %} class="activ-filter"{% endif %}>

{% block object-tools-cms %}

	<ul class="object-tools hide">

    {# Todo: recover link #}
		{% if has_recover_permission %}
			<li><a href="recover/" class="recoverlink">{% blocktrans with cl.opts.verbose_name_plural|escape as name %}Recover deleted {{name}}{% endblocktrans %}</a></li>
		{% endif %}
		{% if has_add_permission %}
		<li><a href="add/{% if is_popup %}?_popup=1{% endif %}" class="addlink">{% blocktrans with cl.opts.verbose_name as name %}Add {{ name }}{% endblocktrans %}</a></li>
		{% endif %}
	</ul>

  {# Todo: loading #}
	{% include "admin/cms/page/loading.html" %}

{% endblock %}
<div class="module{% if cl.has_filters %} filtered{% endif %}" id="changelist">


{% if cl.has_access_to_multiple_sites %}
	<div id="site-selector">{% trans "Pages on:" %}
		<select id="site-select">{% for site in cl.sites %}
			<option {% ifequal site.pk cl.current_site.pk %}selected {% endifequal %}value="{{ site.pk }}">{{ site.name }}</option>{% endfor %}
		</select>
	</div>
{% else %}
	<input type="hidden" id="site-select" value="{{ cl.sites.0.pk }}">
{% endif %}

  <div class="toolbar-content clearfix">
    {% block object-tools %}
      <div class="object-tools">
        {% block object-tools-items %}
          {% if has_add_permission %}
            <a href="add/{% if is_popup %}?_popup=1{% endif %}" class="btn btn-success">
              <i class="icon-plus-sign icon-white"></i>&nbsp;
              {% blocktrans with cl.opts.verbose_name as name %}Add {{ name }}{% endblocktrans %}
            </a>
          {% endif %}
        {% endblock %}
      </div>
    {% endblock %}

    {% block search %}{% search_form cl %}{% endblock %}
  </div>

  {% block date_hierarchy %}
    {% if cl.date_hierarchy %}
      {% date_hierarchy cl %}
    {% endif %}
  {% endblock %}

{% include "admin/cms/page/change_list_tree.html" %}

</div>
</div>

<div id="dialogs"></div>

{% endblock %}
